/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dne.master.tfmtienda.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Noza
 */
@Entity
@Table(name = "compprod")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Compprod.findAll", query = "SELECT c FROM Compprod c"),
    @NamedQuery(name = "Compprod.findByIdCompprod", query = "SELECT c FROM Compprod c WHERE c.idCompprod = :idCompprod"),
    @NamedQuery(name = "Compprod.findByCantidad", query = "SELECT c FROM Compprod c WHERE c.cantidad = :cantidad")})
public class Compprod implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idCompprod")
    private Integer idCompprod;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cantidad")
    private int cantidad;
    @JoinColumn(name = "idProducto", referencedColumnName = "idProducto")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Producto idProducto;
    @JoinColumn(name = "idCompra", referencedColumnName = "idCompra")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Compra idCompra;

    public Compprod() {
    }

    public Compprod(Integer idCompprod) {
        this.idCompprod = idCompprod;
    }

    public Compprod(Integer idCompprod, int cantidad) {
        this.idCompprod = idCompprod;
        this.cantidad = cantidad;
    }

    public Integer getIdCompprod() {
        return idCompprod;
    }

    public void setIdCompprod(Integer idCompprod) {
        this.idCompprod = idCompprod;
    }

    public int getCantidad() {
        return cantidad;
    }

    public void setCantidad(int cantidad) {
        this.cantidad = cantidad;
    }

    public Producto getIdProducto() {
        return idProducto;
    }

    public void setIdProducto(Producto idProducto) {
        this.idProducto = idProducto;
    }

    public Compra getIdCompra() {
        return idCompra;
    }

    public void setIdCompra(Compra idCompra) {
        this.idCompra = idCompra;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCompprod != null ? idCompprod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Compprod)) {
            return false;
        }
        Compprod other = (Compprod) object;
        if ((this.idCompprod == null && other.idCompprod != null) || (this.idCompprod != null && !this.idCompprod.equals(other.idCompprod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dne.master.tfmtienda.entity.Compprod[ idCompprod=" + idCompprod + " ]";
    }
    
}
